package exp;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import tools.ObjectTools;
import tools.webkit.URLJumper;
import tools.webkit.Webpage;

/**
 * Get the realURLs
 * @author Lanjun
 *
 */
public class EXP3_4 {
	public void run(String input, String output, int threadNum) {
		for (File file : (new File(input)).listFiles()) {
			if ((new File(output + file.getName())).exists()) {
				System.err.println("EXP4: " + file.getAbsolutePath() + " already processed!");
				continue;
			}
			
			@SuppressWarnings("unchecked")
			List<Webpage> w = (ArrayList<Webpage>)ObjectTools.readFromFile(file);
			URLJumper u = new URLJumper(threadNum);
			List<Webpage> returned = u.doJump(w);
			ObjectTools.writeToFile(returned, output + file.getName());
		}
	}
	
	public static void main(String[] args) {
		String input = "data/objs/urlContent1_1/";
		String output = "data/objs/urlContent2/";
		
		EXP3_4 exp4 = new EXP3_4();
		exp4.run(input, output, 10);
	}
}
